﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Windows.Forms.Design;

namespace HML.Design
{
    /// <summary>
    /// TrackBarPlus控件设计模式行为
    /// </summary>
    public class TrackBarPlusDesigner : ControlDesigner
    {
        public override SelectionRules SelectionRules
        {
            get
            {
                object component = (object)this.Component;
                PropertyDescriptor propertyDescriptor = TypeDescriptor.GetProperties(component)["Orientation"];
                if (propertyDescriptor != null)
                {
                    TrackBarPlusOrientation Orientation = (TrackBarPlusOrientation)propertyDescriptor.GetValue(component);
                    if (Orientation == TrackBarPlusOrientation.HorizontalTop || Orientation == TrackBarPlusOrientation.HorizontalBottom)
                    {
                        return base.SelectionRules & ~(SelectionRules.TopSizeable | SelectionRules.BottomSizeable);
                    }
                    else
                    {
                        return base.SelectionRules & ~(SelectionRules.LeftSizeable | SelectionRules.RightSizeable);
                    }
                }
                return base.SelectionRules;
            }
        }

    }
}
